﻿using Bilibili.Common;
using Bilibili.Model.Live;
using ReactiveUI;
using System.Collections.ObjectModel;
using System.Reactive;

namespace Avalonia.BiliBili.Views.ViewModels
{
    public class LiveViewModel : ViewModelBase
    {
        public event CallbackNameObject ViewCallback;
        public ReactiveCommand<string, Unit> OnShowMore { get; }
        public ReactiveCommand<object, Unit> OnOpenRoom { get; }
        public ReactiveCommand<object, Unit> OnAreaRoom { get; }
        private ObservableCollection<RoomList> liveRoomList = [];
        private ObservableCollection<LiveAreaEntranceItem> liveAreaList = [];
        public ObservableCollection<LiveAreaEntranceItem> LiveAreaList
        {
            get => liveAreaList;
            private set => this.RaiseAndSetIfChanged(ref liveAreaList, value);
        }
        public ObservableCollection<RoomList> LiveRoomList
        {
            get => liveRoomList;
            private set => this.RaiseAndSetIfChanged(ref liveRoomList, value);
        }
        public LiveViewModel()
        {
            OnShowMore = ReactiveCommand.Create<string>(ShowMore);
            OnAreaRoom = ReactiveCommand.Create<object>(AreaRoom);
            OnOpenRoom = ReactiveCommand.Create<object>(OpenRoom);
        }
        private void AreaRoom(object parameter)
        {
            ViewCallback?.Invoke("area", parameter);
        }
        private void ShowMore(string name)
        {
            ViewCallback?.Invoke("more", name);
        }
        private void OpenRoom(object parameter)
        {
            ViewCallback?.Invoke("room", parameter);
        }
    }
}